﻿namespace Sgr.BillNumbering.Services
{
    /// <summary>
    /// 编码序列生成器接口
    /// </summary>
    public interface ICodeSequence
    {
        /// <summary>
        /// 获取下一个序列值
        /// </summary>
        /// <param name="category">单据类型</param>
        /// <param name="customPrefix">自定义前缀</param>
        /// <param name="resetStrategy">重置策略</param>
        /// <param name="segmentSize">步长</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<long> GetNextValueAsync(
            string category,
            string customPrefix = "",
            SequenceResetStrategy resetStrategy = SequenceResetStrategy.Never,
            int? segmentSize = null,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 清理已过期的缓存段（供后台服务调用）
        /// </summary>
        int CleanupExpiredSegments();
    }
}